<template>
  <div class="personnel">
    <van-form @submit="onSubmit">
      <van-field readonly label="督办意见" label-width="120px" required :border="false" />
      <van-field
        class="van-field__value--textarea"
        name="logContent"
        v-model="serchform.visitRecord"
        rows="12"
        autosize
        type="textarea"
        maxlength="500"
        placeholder="请详细描述工作内容"
        show-word-limit
        :border="false"
        :rules="rules.visitRecord"
      />
      <div class="supervise-today">
        <van-field
          required
          input-align="right"
          v-model="serchform.superviseReplyDate"
          :rules="rules.superviseReplyDate"
          type="number"
          label="答复天数"
        />
        <span>天</span>
      </div>
      <van-field name="checkbox">
        <template #input>
          <van-checkbox v-model="serchform.isShortNote" shape="square" checked-color="#3CBDD0">
            是否进行短信提醒
          </van-checkbox>
        </template>
      </van-field>
      <div style="margin: 16px">
        <van-button round block type="info" native-type="submit">提交</van-button>
      </div>
    </van-form>
  </div>
</template>

<script>
import Cockpit from '@/api/cockpit'
export default {
  name: 'monitoring',
  props: {
    evevtCode: {
      type: String,
      default: ''
    },
    typesuper: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      serchform: {
        recordType: 2,
        button: 1,
        eventCode: '',
        superviseReplyDate: '1',
        visitRecord: '',
        isShortNote: '1'
      },
      rules: {
        visitRecord: [{ required: true, message: '' }],
        superviseReplyDate: [{ required: true, message: '请输入天数' }]
      }
    }
  },
  watch: {
    evevtCode(newVal) {
      this.serchform.eventCode = newVal
    }
  },
  created() {
    this.serchform.eventCode = this.evevtCode
  },
  methods: {
    onSubmit() {
      if (this.serchform.isShortNote === false) {
        this.serchform.isShortNote = '0'
      }
      if (this.typesuper === '2') {
        this.serchform.button = 3
      } else {
        this.serchform.button = 1
      }
      Cockpit.Online.supervise(this.serchform).then(res => {
        this.$toast.success('督办成功')
        this.serchform.visitRecord = ''
        this.serchform.superviseReplyDate = ''
        this.$emit('dubanSucces')
      })
    }
  }
}
</script>

<style scoped lang="less">
@import '~@/assets/style/cockpit/superview.less';
</style>
